package com.jeesite.modules.book.web;

import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.book.entity.AllBook;
import com.jeesite.modules.book.entity.BookCategory;
import com.jeesite.modules.book.service.AllBookService;
import com.jeesite.modules.book.service.BookCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/book")
public class AllBookController extends BaseController{

    @Autowired
    private AllBookService allBookService;

    @Autowired
    private BookCategoryService bookCategoryService;


    @RequestMapping("/category_list")
    @ResponseBody
    public Page<AllBook> listData(AllBook allBook, HttpServletRequest request, HttpServletResponse response) {
        allBook.setPage(new Page<>(request, response));
        Page<AllBook> page = allBookService.findPage(allBook);
        return page;
    }


    @RequestMapping(value = "/book_category")
    @ResponseBody
    public Page<BookCategory> listData(BookCategory bookCategory, HttpServletRequest request, HttpServletResponse response) {
        bookCategory.setPage(new Page<>(request, response));
        Page<BookCategory> page = bookCategoryService.findPage(bookCategory);
        return page;
    }

}
